package com.econ.powercloud.ems.controller.highpressure;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.common.base.facade.pojo.PageResult;
import com.econ.powercloud.ems.controller.ApiBaseController;
import com.econ.powercloud.ems.pojo.ProtectSoeEventRecordVO;
import com.econ.powercloud.ems.pojo.requestVO.ProtectSoeEventRequestVO;
import com.econ.powercloud.ems.service.biz.ProtectAndSoeEventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author : zjf
 * @Description :
 * @Date : 2022/8/3 19:04
 * @Modified by : zjf
 */
@Api(tags = "保护SOE事件")
@RestController
@RequestMapping(value = "/api/v2/protectSoe/event")
public class EmsProtectSoeEventController extends ApiBaseController {

    @Autowired
    private ProtectAndSoeEventService protectAndSoeEventService;

    @ApiOperation(value = "获取保护/SOE事件列表")
    @GetMapping(value = "getList")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNo", value = "页码", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页大小", defaultValue = "20", dataType = "int")
    })
    public MsgResult<PageResult<List<ProtectSoeEventRecordVO>>> getList(@Validated ProtectSoeEventRequestVO requestVO,
                                                                         @RequestParam Integer pageNo,
                                                                         @RequestParam Integer pageSize){
        return successHandler(protectAndSoeEventService.getList(requestVO, pageNo, pageSize));
    }

    @ApiOperation(value = "获取单个保护/SOE事件详情")
    @GetMapping()
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "主键id", dataType = "int")
    })
    public MsgResult<ProtectSoeEventRecordVO> get(@RequestParam Integer id){
        return successHandler(protectAndSoeEventService.get(id));
    }

    @ApiOperation(value = "召唤单个保护事件历史断面数据")
    @GetMapping("calProtectEventById")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "主键id", dataType = "int")
    })
    public MsgResult<String> calProtectEventById(@RequestParam Integer id){
        protectAndSoeEventService.calSectionDataById(id);
        return successHandler("召唤命令下发成功!");
    }

    @ApiOperation(value = "召唤保护事件的历史断面数据")
    @GetMapping("calProtectEvent")
    public MsgResult<String> calProtectEvent(){
        protectAndSoeEventService.calProtectEvent();
        return successHandler("召唤历史断面数据下发成功!");
    }

    @ApiOperation(value = "召唤SOE事件历史数据")
    @GetMapping("calSoeEvent")
    public MsgResult<String> calSoeEvent(){
        protectAndSoeEventService.calSoeEvent();
        return successHandler("召唤历史数据下发成功!");
    }

}
